home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / blstroid.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  14KB  |  406 lines

  1. /***************************************************************************
  2.  
  3. Blasteroids Memory Map
  4. ----------------------
  5.  
  6. BLASTEROIDS 68010 MEMORY MAP
  7.  
  8. Function                           Address        R/W  DATA
  9. -------------------------------------------------------------
  10. Program ROM                        000000-03FFFF  R    D0-D15
  11. Slapstic Program ROM               038000-03FFFF  R    D0-D15
  12.  
  13. Watchdog reset                     FF8000         W    xx
  14. IRQ Acknowledge                    FF8200         W    xx
  15. VBLANK Acknowledge                 FF8400         W    xx
  16. Unlock EEPROM                      FF8600         W    xx
  17.  
  18. Priority RAM (1=MO, 0=PF)          FF8800-FF89FE  W    D0
  19.  
  20. Audio Send Port                    FF8A01         W    D0-D7
  21. Sound Processor Reset              FF8C00         W    xx
  22. Halt CPU until HBLANK              FF8E00         W    xx
  23.  
  24. Audio Receive Port                 FF9401         R    D0-D7
  25. Whirly-Gig (Player 1)              FF9801         R    D0-D7
  26. Whirly-Gig (Player 2)              FF9805         R    D0-D7
  27.  
  28. Self-Test                          FF9C01         R    D7
  29. Audio Busy Flag                                   R    D6
  30. Vertical Blank                                    R    D5
  31. Horizontal Blank                                  R    D4
  32. Player 1 Button 4                                 R    D3
  33. Player 1 Transform                                R    D2
  34. Player 1 Thrust                                   R    D1
  35. Player 1 Fire                                     R    D0
  36.  
  37. Player 2 Button 4                  FF9C03         R    D3
  38. Player 2 Transform                                R    D2
  39. Player 2 Thrust                                   R    D1
  40. Player 2 Fire                                     R    D0
  41.  
  42. Color RAM Motion Object            FFA000-FFA1FE  R/W  D0-D14
  43. Color RAM Playfield                FFA200-FFA2FE  R/W  D0-D14
  44.  
  45. EEPROM                             FFB001-FFB3FF  R/W  D0-D7
  46.  
  47. Playfield RAM (40x30)              FFC000-FFCFFF  R/W  D0-D15
  48. Row Programmable Interrupt         FFC050-FFCED0  R/W  D15
  49.  
  50. Motion Object V Position           FFD000-FFDFF8  R/W  D7-D15
  51. Motion Object V Size                              R/W  D0-D3
  52. Motion Object H Flip               FFD002-FFDFFA  R/W  D15
  53. Motion Object V Flip                              R/W  D14
  54. Motion Object Stamp                               R/W  D0-D13
  55. Motion Object Link                 FFD004-FFDFFC  R/W  D3-D11
  56. Motion Object H Position           FFD006-FFDFFE  R/W  D6-D15
  57. Motion Object Palette                             R/W  D0-D3
  58.  
  59. RAM                                FFE000-FFFFFF  R/W
  60.  
  61. ****************************************************************************/
  62.  
  63.  
  64.  
  65. #include "driver.h"
  66. #include "machine/atarigen.h"
  67. #include "sndhrdw/atarijsa.h"
  68. #include "vidhrdw/generic.h"
  69.  
  70.  
  71. WRITE_HANDLER( blstroid_priorityram_w );
  72. WRITE_HANDLER( blstroid_playfieldram_w );
  73.  
  74. int blstroid_vh_start(void);
  75. void blstroid_vh_stop(void);
  76. void blstroid_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  77.  
  78. void blstroid_scanline_update(int scanline);
  79.  
  80.  
  81.  
  82. /*************************************
  83.  *
  84.  *    Initialization
  85.  *
  86.  *************************************/
  87.  
  88. static void update_interrupts(void)
  89. {
  90.     int newstate = 0;
  91.  
  92.     if (atarigen_scanline_int_state)
  93.         newstate = 1;
  94.     if (atarigen_video_int_state)
  95.         newstate = 2;
  96.     if (atarigen_sound_int_state)
  97.         newstate = 4;
  98.  
  99.     if (newstate)
  100.         cpu_set_irq_line(0, newstate, ASSERT_LINE);
  101.     else
  102.         cpu_set_irq_line(0, 7, CLEAR_LINE);
  103. }
  104.  
  105.  
  106. static void init_machine(void)
  107. {
  108.     atarigen_eeprom_reset();
  109.     atarigen_interrupt_reset(update_interrupts);
  110.     atarigen_scanline_timer_reset(blstroid_scanline_update, 8);
  111.     atarijsa_reset();
  112. }
  113.  
  114.  
  115.  
  116. /*************************************
  117.  *
  118.  *    I/O read dispatch
  119.  *
  120.  *************************************/
  121.  
  122. static READ_HANDLER( special_port2_r )
  123. {
  124.     int temp = input_port_2_r(offset);
  125.     if (atarigen_cpu_to_sound_ready) temp ^= 0x0040;
  126.     if (atarigen_get_hblank()) temp ^= 0x0010;
  127.     return temp;
  128. }
  129.  
  130.  
  131.  
  132. /*************************************
  133.  *
  134.  *    Main CPU memory handlers
  135.  *
  136.  *************************************/
  137.  
  138. static struct MemoryReadAddress main_readmem[] =
  139. {
  140.     { 0x000000, 0x03ffff, MRA_ROM },
  141.     { 0xff9400, 0xff9401, atarigen_sound_r },
  142.     { 0xff9800, 0xff9801, input_port_0_r },
  143.     { 0xff9804, 0xff9805, input_port_1_r },
  144.     { 0xff9c00, 0xff9c01, special_port2_r },
  145.     { 0xff9c02, 0xff9c03, input_port_3_r },
  146.     { 0xffa000, 0xffa3ff, paletteram_word_r },
  147.     { 0xffb000, 0xffb3ff, atarigen_eeprom_r },
  148.     { 0xffc000, 0xffcfff, MRA_BANK1 },
  149.     { 0xffd000, 0xffdfff, MRA_BANK2 },
  150.     { 0xffe000, 0xffffff, MRA_BANK3 },
  151.     { -1 }  /* end of table */
  152. };
  153.  
  154.  
  155. static struct MemoryWriteAddress main_writemem[] =
  156. {
  157.     { 0x000000, 0x03ffff, MWA_ROM },
  158.     { 0xff8000, 0xff8001, watchdog_reset_w },
  159.     { 0xff8200, 0xff8201, atarigen_scanline_int_ack_w },
  160.     { 0xff8400, 0xff8401, atarigen_video_int_ack_w },
  161.     { 0xff8600, 0xff8601, atarigen_eeprom_enable_w },
  162.     { 0xff8800, 0xff89ff, blstroid_priorityram_w },
  163.     { 0xff8a00, 0xff8a01, atarigen_sound_w },
  164.     { 0xff8c00, 0xff8c01, atarigen_sound_reset_w },
  165.     { 0xff8e00, 0xff8e01, atarigen_halt_until_hblank_0_w },
  166.     { 0xffa000, 0xffa3ff, paletteram_xRRRRRGGGGGBBBBB_word_w, &paletteram },
  167.     { 0xffb000, 0xffb3ff, atarigen_eeprom_w, &atarigen_eeprom, &atarigen_eeprom_size },
  168.     { 0xffc000, 0xffcfff, blstroid_playfieldram_w, &atarigen_playfieldram, &atarigen_playfieldram_size },
  169.     { 0xffd000, 0xffdfff, MWA_BANK2, &atarigen_spriteram, &atarigen_spriteram_size },
  170.     { 0xffe000, 0xffffff, MWA_BANK3 },
  171.     { -1 }  /* end of table */
  172. };
  173.  
  174.  
  175.  
  176. /*************************************
  177.  *
  178.  *    Port definitions
  179.  *
  180.  *************************************/
  181.  
  182. INPUT_PORTS_START( blstroid )
  183.     PORT_START      /* ff9800 */
  184.     PORT_ANALOG( 0x00ff, 0, IPT_DIAL | IPF_PLAYER1, 60, 10, 0, 0 )
  185.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  186.  
  187.     PORT_START      /* ff9804 */
  188.     PORT_ANALOG( 0x00ff, 0, IPT_DIAL | IPF_PLAYER2, 60, 10, 0, 0 )
  189.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  190.  
  191.     PORT_START        /* ff9c00 */
  192.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  193.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  194.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
  195.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER1 )
  196.     PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_UNUSED )
  197.     PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_VBLANK )
  198.     PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
  199.     PORT_SERVICE( 0x0080, IP_ACTIVE_LOW )
  200.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  201.  
  202.     PORT_START        /* ff9c02 */
  203.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  204.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  205.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  206.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2 )
  207.     PORT_BIT( 0xfff0, IP_ACTIVE_LOW, IPT_UNUSED )
  208.  
  209.     JSA_I_PORT    /* audio board port */
  210. INPUT_PORTS_END
  211.  
  212.  
  213.  
  214. /*************************************
  215.  *
  216.  *    Graphics definitions
  217.  *
  218.  *************************************/
  219.  
  220. static struct GfxLayout pflayout =
  221. {
  222.     16,8,    /* 16*8 chars (doubled horizontally) */
  223.     8192,    /* 8192 chars */
  224.     4,        /* 4 bits per pixel */
  225.     { 0, 1, 2, 3 },
  226.     { 0,0, 4,4, 8,8, 12,12, 16,16, 20,20, 24,24, 28,28 },
  227.     { 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8 },
  228.     32*8    /* every char takes 32 consecutive bytes */
  229. };
  230.  
  231.  
  232. static struct GfxLayout molayout =
  233. {
  234.     16,8,    /* 16*8 chars */
  235.     16384,    /* 16384 chars */
  236.     4,        /* 4 bits per pixel */
  237.     { 0, 1, 2, 3 },
  238.     { 0x80000*8+0, 0x80000*8+4, 0, 4, 0x80000*8+8, 0x80000*8+12, 8, 12,
  239.             0x80000*8+16, 0x80000*8+20, 16, 20, 0x80000*8+24, 0x80000*8+28, 24, 28 },
  240.     { 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8 },
  241.     32*8    /* every char takes 32 consecutive bytes */
  242. };
  243.  
  244.  
  245. static struct GfxDecodeInfo gfxdecodeinfo[] =
  246. {
  247.     { REGION_GFX1, 0, &pflayout,  256, 16 },
  248.     { REGION_GFX2, 0, &molayout,    0, 16 },
  249.     { -1 } /* end of array */
  250. };
  251.  
  252.  
  253.  
  254. /*************************************
  255.  *
  256.  *    Machine driver
  257.  *
  258.  *************************************/
  259.  
  260. static struct MachineDriver machine_driver_blstroid =
  261. {
  262.     /* basic machine hardware */
  263.     {
  264.         {
  265.             CPU_M68000,        /* verified */
  266.             ATARI_CLOCK_14MHz/2,
  267.             main_readmem,main_writemem,0,0,
  268.             atarigen_video_int_gen,1
  269.         },
  270.         JSA_I_CPU
  271.     },
  272.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  273.     1,
  274.     init_machine,
  275.  
  276.     /* video hardware */
  277.     40*16, 30*8, { 0*8, 40*16-1, 0*8, 30*8-1 },
  278.     gfxdecodeinfo,
  279.     512,512,
  280.     0,
  281.  
  282.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK |
  283.             VIDEO_SUPPORTS_DIRTY | VIDEO_PIXEL_ASPECT_RATIO_1_2,
  284.     0,
  285.     blstroid_vh_start,
  286.     blstroid_vh_stop,
  287.     blstroid_vh_screenrefresh,
  288.  
  289.     /* sound hardware */
  290.     JSA_I_STEREO,
  291.  
  292.     atarigen_nvram_handler
  293. };
  294.  
  295.  
  296.  
  297. /*************************************
  298.  *
  299.  *    ROM definition(s)
  300.  *
  301.  *************************************/
  302.  
  303. ROM_START( blstroid )
  304.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 4*64k for 68000 code */
  305.     ROM_LOAD_EVEN( "057-4123",  0x00000, 0x10000, 0xd14badc4 )
  306.     ROM_LOAD_ODD ( "057-4121",  0x00000, 0x10000, 0xae3e93e8 )
  307.     ROM_LOAD_EVEN( "057-4124",  0x20000, 0x10000, 0xfd2365df )
  308.     ROM_LOAD_ODD ( "057-4122",  0x20000, 0x10000, 0xc364706e )
  309.  
  310.     ROM_REGION( 0x14000, REGION_CPU2 )    /* 64k for 6502 code */
  311.     ROM_LOAD( "blstroid.snd", 0x10000, 0x4000, 0xbaa8b5fe )
  312.     ROM_CONTINUE(             0x04000, 0xc000 )
  313.  
  314.     ROM_REGION( 0x040000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  315.     ROM_LOAD( "blstroid.1l",  0x000000, 0x10000, 0x3c2daa5b ) /* playfield */
  316.     ROM_LOAD( "blstroid.1m",  0x010000, 0x10000, 0xf84f0b97 ) /* playfield */
  317.     ROM_LOAD( "blstroid.3l",  0x020000, 0x10000, 0xae5274f0 ) /* playfield */
  318.     ROM_LOAD( "blstroid.3m",  0x030000, 0x10000, 0x4bb72060 ) /* playfield */
  319.  
  320.     ROM_REGION( 0x100000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  321.     ROM_LOAD( "blstroid.5m",  0x000000, 0x10000, 0x50e0823f ) /* mo */
  322.     ROM_LOAD( "blstroid.6m",  0x010000, 0x10000, 0x729de7a9 ) /* mo */
  323.     ROM_LOAD( "blstroid.8m",  0x020000, 0x10000, 0x090e42ab ) /* mo */
  324.     ROM_LOAD( "blstroid.10m", 0x030000, 0x10000, 0x1ff79e67 ) /* mo */
  325.     ROM_LOAD( "blstroid.11m", 0x040000, 0x10000, 0x4be1d504 ) /* mo */
  326.     ROM_LOAD( "blstroid.13m", 0x050000, 0x10000, 0xe4409310 ) /* mo */
  327.     ROM_LOAD( "blstroid.14m", 0x060000, 0x10000, 0x7aaca15e ) /* mo */
  328.     ROM_LOAD( "blstroid.16m", 0x070000, 0x10000, 0x33690379 ) /* mo */
  329.     ROM_LOAD( "blstroid.5n",  0x080000, 0x10000, 0x2720ee71 ) /* mo */
  330.     ROM_LOAD( "blstroid.6n",  0x090000, 0x10000, 0x2faecd15 ) /* mo */
  331.     ROM_LOAD( "blstroid.8n",  0x0a0000, 0x10000, 0xf10e59ed ) /* mo */
  332.     ROM_LOAD( "blstroid.10n", 0x0b0000, 0x10000, 0x4d5fc284 ) /* mo */
  333.     ROM_LOAD( "blstroid.11n", 0x0c0000, 0x10000, 0xa70fc6e6 ) /* mo */
  334.     ROM_LOAD( "blstroid.13n", 0x0d0000, 0x10000, 0xf423b4f8 ) /* mo */
  335.     ROM_LOAD( "blstroid.14n", 0x0e0000, 0x10000, 0x56fa3d16 ) /* mo */
  336.     ROM_LOAD( "blstroid.16n", 0x0f0000, 0x10000, 0xf257f738 ) /* mo */
  337. ROM_END
  338.  
  339.  
  340. ROM_START( blstroi2 )
  341.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 4*64k for 68000 code */
  342.     ROM_LOAD_EVEN( "blstroid.6c",  0x00000, 0x10000, 0x5a092513 )
  343.     ROM_LOAD_ODD ( "blstroid.6b",  0x00000, 0x10000, 0x486aac51 )
  344.     ROM_LOAD_EVEN( "blstroid.4c",  0x20000, 0x10000, 0xd0fa38fe )
  345.     ROM_LOAD_ODD ( "blstroid.4b",  0x20000, 0x10000, 0x744bf921 )
  346.  
  347.     ROM_REGION( 0x14000, REGION_CPU2 )    /* 64k for 6502 code */
  348.     ROM_LOAD( "blstroid.snd", 0x10000, 0x4000, 0xbaa8b5fe )
  349.     ROM_CONTINUE(             0x04000, 0xc000 )
  350.  
  351.     ROM_REGION( 0x040000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  352.     ROM_LOAD( "blstroid.1l",  0x000000, 0x10000, 0x3c2daa5b ) /* playfield */
  353.     ROM_LOAD( "blstroid.1m",  0x010000, 0x10000, 0xf84f0b97 ) /* playfield */
  354.     ROM_LOAD( "blstroid.3l",  0x020000, 0x10000, 0xae5274f0 ) /* playfield */
  355.     ROM_LOAD( "blstroid.3m",  0x030000, 0x10000, 0x4bb72060 ) /* playfield */
  356.  
  357.     ROM_REGION( 0x100000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  358.     ROM_LOAD( "blstroid.5m",  0x000000, 0x10000, 0x50e0823f ) /* mo */
  359.     ROM_LOAD( "blstroid.6m",  0x010000, 0x10000, 0x729de7a9 ) /* mo */
  360.     ROM_LOAD( "blstroid.8m",  0x020000, 0x10000, 0x090e42ab ) /* mo */
  361.     ROM_LOAD( "blstroid.10m", 0x030000, 0x10000, 0x1ff79e67 ) /* mo */
  362.     ROM_LOAD( "blstroid.11m", 0x040000, 0x10000, 0x4be1d504 ) /* mo */
  363.     ROM_LOAD( "blstroid.13m", 0x050000, 0x10000, 0xe4409310 ) /* mo */
  364.     ROM_LOAD( "blstroid.14m", 0x060000, 0x10000, 0x7aaca15e ) /* mo */
  365.     ROM_LOAD( "blstroid.16m", 0x070000, 0x10000, 0x33690379 ) /* mo */
  366.     ROM_LOAD( "blstroid.5n",  0x080000, 0x10000, 0x2720ee71 ) /* mo */
  367.     ROM_LOAD( "blstroid.6n",  0x090000, 0x10000, 0x2faecd15 ) /* mo */
  368.     ROM_LOAD( "blstroid.8n",  0x0a0000, 0x10000, 0xf10e59ed ) /* mo */
  369.     ROM_LOAD( "blstroid.10n", 0x0b0000, 0x10000, 0x4d5fc284 ) /* mo */
  370.     ROM_LOAD( "blstroid.11n", 0x0c0000, 0x10000, 0xa70fc6e6 ) /* mo */
  371.     ROM_LOAD( "blstroid.13n", 0x0d0000, 0x10000, 0xf423b4f8 ) /* mo */
  372.     ROM_LOAD( "blstroid.14n", 0x0e0000, 0x10000, 0x56fa3d16 ) /* mo */
  373.     ROM_LOAD( "blstroid.16n", 0x0f0000, 0x10000, 0xf257f738 ) /* mo */
  374. ROM_END
  375.  
  376.  
  377.  
  378. /*************************************
  379.  *
  380.  *    Driver initialization
  381.  *
  382.  *************************************/
  383.  
  384. static void init_blstroid(void)
  385. {
  386.     atarigen_eeprom_default = NULL;
  387.     atarijsa_init(1, 4, 2, 0x80);
  388.  
  389.     /* speed up the 6502 */
  390.     atarigen_init_6502_speedup(1, 0x4157, 0x416f);
  391.  
  392.     /* display messages */
  393.     atarigen_show_sound_message();
  394. }
  395.  
  396.  
  397.  
  398. /*************************************
  399.  *
  400.  *    Game driver(s)
  401.  *
  402.  *************************************/
  403.  
  404. GAME( 1987, blstroid, 0,        blstroid, blstroid, blstroid, ROT0, "Atari Games", "Blasteroids (version 4)" )
  405. GAME( 1987, blstroi2, blstroid, blstroid, blstroid, blstroid, ROT0, "Atari Games", "Blasteroids (version 2)" )
  406.